<template>
  <div class="diyVideoControl">
    <div class="control-section">
      <div class="control-header">
        <span>视频</span>
        <span @click.stop="showBeautyBox = true" style="cursor: pointer;">组件美化</span>
      </div>
      <div class="control-body">
        <div class="moudleNameBox">
          <div class="control-head">
            <p class="section-name">文字组件</p>
            <p class="reset" @click.stop="params.params.text = '视频'">重置</p>
          </div>
          <div class="moduleName">
            <div class="nameText">
              <input type="text" v-model="params.params.text" placeholder="请输入模板标题"/>
            </div>
            <div class="show">
              <i class="iconfont icon-xianshi" @click.stop="params.params.useTitle = 2" v-if="params.params.useTitle == 1"></i>
              <i class="iconfont icon-yincang" @click.stop="params.params.useTitle = 1" v-else></i>
            </div>
          </div>
        </div>
        <uploadVideo :uploadVideo="params.params.videoUrl" :title="'添加视频'" @deleteImg="params.params.videoUrl = ''" @uploadSuccess="uploadVideoSuccess"></uploadVideo>
        <uploadImg size="750*350px" :uploadImg="params.params.picUrl" @deleteImg="params.params.picUrl = ''" :title="'添加封面'" @uploadSuccess="uploadSuccess"></uploadImg>
      </div>
    </div>
    <!-- 组件美化 -->
    <comBeautyBox
      :showBeautyBox="showBeautyBox"
      @handleBack="showBeautyBox = false"
    >
      <div>
        <!-- 字体配置 -->
        <bgControl :backgroudData="params.moduleCss"></bgControl>
        <!-- 间距圆角控制 -->
        <spaceControl
          :spaceData.sync="params.moduleCss"
          @resetSpace="resetSpace"
          @resetMp="resetMp"
        ></spaceControl>
      </div>
    </comBeautyBox>
  </div>
</template>


<script>
import comBeautyBox from "@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue";
import bgControl from "@/components/DiyNew/diy/baseControl/bgControl/index.vue";
import uploadImg from "@/components/DiyNew/uploadImg/index.vue";
import uploadVideo from "@/components/DiyNew/uploadVideo/index.vue";
import spaceControl from "@/components/DiyNew/diy/baseControl/spaceControl/index.vue";
export default {
  name: "diyVideoControl",
  components: {
    comBeautyBox,
    bgControl,
    uploadImg,
    uploadVideo,
    spaceControl
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
      choosedTab: {},
      showBeautyBox:false
    };
  },
  methods: {
    uploadSuccess(e) {
      console.log(e);
      this.$setWithAction(this.params.params, "picUrl", e.val)
      // this.params.params.picUrl = e.val
    },
    uploadVideoSuccess(e) {
      this.$setWithAction(this.params.params, "videoUrl", e.val)
      // this.params.params.videoUrl = e.val
    },
    // 重置圆角
    resetSpace(e) {
      let type = e.type;
      this.$set(this.params.moduleCss, type, 0);
    },
    // 重置边距
    resetMp() {
      this.$set(this.params.moduleCss, "margin", 0);
      this.$set(this.params.moduleCss, "padding", 0);
    }
  },
};
</script>


<style lang="scss" scoped>
.control-section {
  width: 100%;
  margin: 0 auto;
  text-align: center;
  .control-header {
    width: 100%;
    height: 48px;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    span:first-child {
      font-weight: 600;
      color: #000000;
    }
    span:last-child {
      font-size: 12px;
      color: #8c8c8c;
    }
  }
  .control-body {
    width: 228px;
    margin: 0 auto;
  }
}
.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 12px 0;
  font-size: 12px;
  font-weight: 400;
  color: #000000;
  .reset {
    font-size: 12px;
    font-weight: 400;
    color: #8e8e8e;
    cursor: pointer;
    user-select: none;
  }
  p {
    margin: 0;
  }
}
.moduleName {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .nameText {
    width: 196px;
    height: 40px;
    background-color: #f6f7f9;
    border-radius: 4px;
    padding: 0 14px;
    input {
        width: 100%;
        height: 100%;
        border: none;
        outline: none;
        background-color: #f6f7f9;
    }
  }
  .show {
      width: 24px;
      height: 24px;
      background-color: #f6f7f9;
      border-radius: 4px;
      cursor: pointer;
      color: #000000;
  }
}
</style>